
package org.bridgen.lang.semantics.ast;
import java.util.*;


public class JavaAttrDecl extends AttrDecl implements Cloneable {
    public void flushCache() {
        super.flushCache();
    }
     @SuppressWarnings({"unchecked", "cast"})  public JavaAttrDecl clone() throws CloneNotSupportedException {
        JavaAttrDecl node = (JavaAttrDecl)super.clone();
        node.in$Circle(false);
        node.is$Final(false);
    return node;
    }
     @SuppressWarnings({"unchecked", "cast"})  public JavaAttrDecl copy() {
      try {
          JavaAttrDecl node = (JavaAttrDecl)clone();
          if(children != null) node.children = (ASTNode[])children.clone();
          return node;
      } catch (CloneNotSupportedException e) {
      }
      System.err.println("Error: Could not clone node of type " + getClass().getName() + "!");
      return null;
    }
     @SuppressWarnings({"unchecked", "cast"})  public JavaAttrDecl fullCopy() {
        JavaAttrDecl res = (JavaAttrDecl)copy();
        for(int i = 0; i < getNumChildNoTransform(); i++) {
          ASTNode node = getChildNoTransform(i);
          if(node != null) node = node.fullCopy();
          res.setChild(node, i);
        }
        return res;
    }
    // Declared in PrettyPrint.jrag at line 148

    
    public void pp(StringBuffer buf) {
    	buf.append(indent() + "java-attr " + getReturnType() + " ");
    	getNodeUse().pp(buf);
    	buf.append("." + getName() + " = ");
    	getJavaBlock().pp(buf);
    	buf.append("\n");
    }

    // Declared in TypeCodeGen.jrag at line 749

	
	public void generateCode(String indent, StringBuffer buf) {
		super.generateCode(indent, buf);
		
		// Method signature
		buf.append(indent + "protected " + cacheVariableType() + " " + computeMethod() + "() {\n");
		 
		// Method body
		buf.append(indent + INDENT + "// Non-generated code start\n");
		buf.append(indent + INDENT + getJavaBlock().getContent() + "\n");
		buf.append(indent + INDENT + "// Non-generated code end\n");
		buf.append(indent + "}\n\n");  
	}

    // Declared in bridgit.ast at line 3
    // Declared in bridgit.ast line 38

    public JavaAttrDecl() {
        super();


    }

    // Declared in bridgit.ast at line 10


    // Declared in bridgit.ast line 38
    public JavaAttrDecl(NodeUse p0, String p1, String p2, JavaBlock p3) {
        setChild(p0, 0);
        setName(p1);
        setReturnType(p2);
        setChild(p3, 1);
    }

    // Declared in bridgit.ast at line 17


  protected int numChildren() {
    return 2;
  }

    // Declared in bridgit.ast at line 20

  public boolean mayHaveRewrite() { return false; }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 36
    public void setNodeUse(NodeUse node) {
        setChild(node, 0);
    }

    // Declared in bridgit.ast at line 5

    public NodeUse getNodeUse() {
        return (NodeUse)getChild(0);
    }

    // Declared in bridgit.ast at line 9


    public NodeUse getNodeUseNoTransform() {
        return (NodeUse)getChildNoTransform(0);
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 36
    public void setName(String value) {
        tokenString_Name = value;
    }

    // Declared in bridgit.ast at line 5

    public String getName() {
        return tokenString_Name != null ? tokenString_Name : "";
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 38
    protected String tokenString_ReturnType;

    // Declared in bridgit.ast at line 3

    public void setReturnType(String value) {
        tokenString_ReturnType = value;
    }

    // Declared in bridgit.ast at line 6

    public String getReturnType() {
        return tokenString_ReturnType != null ? tokenString_ReturnType : "";
    }

    // Declared in bridgit.ast at line 2
    // Declared in bridgit.ast line 38
    public void setJavaBlock(JavaBlock node) {
        setChild(node, 1);
    }

    // Declared in bridgit.ast at line 5

    public JavaBlock getJavaBlock() {
        return (JavaBlock)getChild(1);
    }

    // Declared in bridgit.ast at line 9


    public JavaBlock getJavaBlockNoTransform() {
        return (JavaBlock)getChildNoTransform(1);
    }

    // Declared in TypeAnalysis.jrag at line 76
 @SuppressWarnings({"unchecked", "cast"})     public String returnType() {
        String returnType_value = returnType_compute();
        return returnType_value;
    }

    private String returnType_compute() {  return getReturnType();  }

    // Declared in TypeCodeGen.jrag at line 747
 @SuppressWarnings({"unchecked", "cast"})     public String cacheVariableType() {
        String cacheVariableType_value = cacheVariableType_compute();
        return cacheVariableType_value;
    }

    private String cacheVariableType_compute() {  return getReturnType();  }

    // Declared in PrettyPrint.jrag at line 28
    public String Define_String_indent(ASTNode caller, ASTNode child) {
        if(caller == getJavaBlockNoTransform()) {
            return indent() + "  ";
        }
        return getParent().Define_String_indent(this, caller);
    }

public ASTNode rewriteTo() {
    return super.rewriteTo();
}

}
